home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Tcl_SetResult C Library Procedures Tcl_SetResult
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Tcl_SetResult, Tcl_AppendResult, Tcl_AppendElement,
- Tcl_ResetResult - manipulate Tcl result string
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ttccll..hh>>
-
- TTccll__SSeettRReessuulltt(_i_n_t_e_r_p, _s_t_r_i_n_g, _f_r_e_e_P_r_o_c) |
-
- TTccll__AAppppeennddRReessuulltt((_i_n_t_e_r_p, _s_t_r_i_n_g, _s_t_r_i_n_g, ... , ((cchhaarr **)) NNUULLLL)
-
- TTccll__AAppppeennddEElleemmeenntt(_i_n_t_e_r_p, _s_t_r_i_n_g, _n_o_S_e_p) |
-
- TTccll__RReesseettRReessuulltt(_i_n_t_e_r_p) |
-
- TTccll__FFrreeeeRReessuulltt(_i_n_t_e_r_p) |
-
- AARRGGUUMMEENNTTSS
- Tcl_Interp *_i_n_t_e_r_p (out) Interpreter whose result
- is to be modified.
-
- char *_s_t_r_i_n_g (in) String value to become
- result for _i_n_t_e_r_p or to
- be appended to existing
- result.
-
- Tcl_FreeProc _f_r_e_e_P_r_o_c (in) Address of procedure to |
- call to release storage |
- at _s_t_r_i_n_g, or |
- TTCCLL__SSTTAATTIICC, TTCCLL__DDYYNNAAMMIICC, |
- or TTCCLL__VVOOLLAATTIILLEE. |
-
- int _n_o_S_e_p (in) ||
- If non-zero then don't |
- output a space character |
- before this element, |
- even if the element |
- isn't the first thing in |
- the result string.
- _________________________________________________________________
-
-
- DDEESSCCRRIIPPTTIIOONN
- The procedures described here are utilities for setting the
- result/error string in a Tcl interpreter.
-
- TTccll__SSeettRReessuulltt arranges for _s_t_r_i_n_g to be the return string
- for the current Tcl command in _i_n_t_e_r_p, replacing any exist-
- ing result. If _f_r_e_e_P_r_o_c is TTCCLL__SSTTAATTIICC it means that _s_t_r_i_n_g |
- refers to an area of static storage that is guaranteed not |
-
-
-
- Sprite v1.0 1
-
-
-
-
-
-
- Tcl_SetResult C Library Procedures Tcl_SetResult
-
-
-
- to be modified until at least the next call to TTccll__EEvvaall. If |
- _f_r_e_e_P_r_o_c is TTCCLL__DDYYNNAAMMIICC it means that _s_t_r_i_n_g was allocated |
- with a call to mmaalllloocc(()) and is now the property of the Tcl |
- system. TTccll__SSeettRReessuulltt will arrange for the string's storage |
- to be released by calling ffrreeee(()) when it is no longer |
- needed. If _f_r_e_e_P_r_o_c is TTCCLL__VVOOLLAATTIILLEE it means that _s_t_r_i_n_g |
- points to an area of memory that is likely to be overwritten |
- when TTccll__SSeettRReessuulltt returns (e.g. it points to something in a |
- stack frame). In this case TTccll__SSeettRReessuulltt will make a copy |
- of the string in dynamically allocated storage and arrange |
- for the copy to be the return string for the current Tcl |
- command. |
-
- If _f_r_e_e_P_r_o_c isn't one of the values TTCCLL__SSTTAATTIICC, TTCCLL__DDYYNNAAMMIICC, |
- and TTCCLL__VVOOLLAATTIILLEE, then it is the address of a procedure that |
- Tcl should call to free the string. This allows applica- |
- tions to use non-standard storage allocators. When Tcl no |
- longer needs the storage for the string, it will call |
- _f_r_e_e_P_r_o_c. _F_r_e_e_P_r_o_c should have arguments and result that |
- match the type TTccll__FFrreeeePPrroocc: |
-
- typedef void Tcl_FreeProc(char *_b_l_o_c_k_P_t_r); |
-
- When _f_r_e_e_P_r_o_c is called, its _b_l_o_c_k_P_t_r will be set to the |
- value of _s_t_r_i_n_g passed to TTccll__SSeettRReessuulltt.
-
- If _s_t_r_i_n_g is NNUULLLL, then _f_r_e_e_P_r_o_c is ignored and
- TTccll__SSeettRReessuulltt re-initializes _i_n_t_e_r_p's result to point to the
- pre-allocated result area, with an empty string in the
- result area.
-
- If TTccll__SSeettRReessuulltt is called at a time when _i_n_t_e_r_p holds a |
- result, TTccll__SSeettRReessuulltt does whatever is necessary to dispose |
- of the old result (see the TTccll__IInntteerrpp manual entry for |
- details on this).
-
- TTccll__AAppppeennddRReessuulltt makes it easy to build up Tcl results in
- pieces. It takes each of its _s_t_r_i_n_g arguments and appends
- them in order to the current result associated with _i_n_t_e_r_p. |
- If the result is in its initialized empty state (e.g. a com- |
- mand procedure was just invoked or TTccll__RReesseettRReessuulltt was just |
- called), then TTccll__AAppppeennddRReessuulltt sets the result to the con- |
- catenation of its _s_t_r_i_n_g arguments. TTccll__AAppppeennddRReessuulltt may be
- called repeatedly as additional pieces of the result are
- produced. TTccll__AAppppeennddRReessuulltt takes care of all the storage
- management issues associated with managing _i_n_t_e_r_p's result,
- such as allocating a larger result area if necessary. Any
- number of _s_t_r_i_n_g arguments may be passed in a single call;
- the last argument in the list must be a NULL pointer.
-
- TTccll__AAppppeennddEElleemmeenntt is similar to TTccll__AAppppeennddRReessuulltt in that it |
- allows results to be built up in pieces. However, |
-
-
-
- Sprite v1.0 2
-
-
-
-
-
-
- Tcl_SetResult C Library Procedures Tcl_SetResult
-
-
-
- TTccll__AAppppeennddEElleemmeenntt takes only a single _s_t_r_i_n_g argument and it |
- appends that argument to the current result as a proper Tcl |
- list element. TTccll__AAppppeennddEElleemmeenntt adds backslashes or braces |
- if necessary to ensure that _i_n_t_e_r_p's result can be parsed as |
- a list and that _s_t_r_i_n_g will be extracted as a single ele- |
- ment. Under normal conditions, TTccll__AAppppeennddEElleemmeenntt will add a |
- space character to _i_n_t_e_r_p's result just before adding the |
- new list element, so that the list elements in the result |
- are properly separated. However, if _i_n_t_e_r_p's result is |
- empty when TTccll__AAppppeennddEElleemmeenntt is called, or if the _n_o_S_e_p |
- argument is 1, then no space is added. |
-
- TTccll__RReesseettRReessuulltt clears the result for _i_n_t_e_r_p, freeing the |
- memory associated with it if the current result was dynami- |
- cally allocated. It leaves the result in its normal ini- |
- tialized state with _i_n_t_e_r_p->_r_e_s_u_l_t pointing to a static |
- buffer containing TTCCLL__RREESSUULLTT__SSIIZZEE characters, of which the |
- first character is zero. TTccll__RReesseettRReessuulltt also clears the |
- error state managed by TTccll__AAddddEErrrroorrIInnffoo and |
- TTccll__SSeettEErrrroorrCCooddee. |
-
- TTccll__FFrreeeeRReessuulltt is a macro that performs part of the work of |
- TTccll__RReesseettRReessuulltt. It frees up the memory associated with |
- _i_n_t_e_r_p's result and sets _i_n_t_e_r_p->_f_r_e_e_P_r_o_c to zero, but it |
- doesn't change _i_n_t_e_r_p->_r_e_s_u_l_t or clear error state. |
- TTccll__FFrreeeeRReessuulltt is most commonly used when a procedure is |
- about to replace one result value with another.
-
-
- SSEEEE AALLSSOO
- Tcl_AddErrorInfo, Tcl_SetErrorCode, Tcl_Interp
-
-
- KKEEYYWWOORRDDSS
- append, command, element, list, result, return value, inter-
- preter
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v1.0 3
-
-
-
-